home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
stazsoftware.com
/
www.stazsoftware.com.tar
/
www.stazsoftware.com
/
futurebasic
/
sample-code
/
FileWritable.sit
/
FN FBFileWritable
next >
Wrap
Text File
|
2003-08-25
|
2KB
|
72 lines
/*
while this has been presented as an entire program, the real meat is a single, tiny
function called...
FN FBFileWritable( fs as ^FSSpec)
it returns zero or one to say that you can write to the file [1] or not [0]. it's pretty
well idiot proof [until they invent a new idiot.
*/
'------------------------ Begin Test Program -----------------------
'
' 0 = No way, no how, can I write to this file
' 1 = Exists and writable
'
'~'1
clear local mode
dim err
dim @ ref%
dim f as FSSpec
local fn FBFileWritable( fs as ^FSSpec)
f = fs
err = FN FSpOpenDF(f,_fswrperm,ref)
if err == 0 then err = fn fsclose(ref)
end fn = (err == 0)' 1 = OK & Can Write!
'~'1
clear local fn doMenu
dim as long menuid, itemid, id, k
dim Afile$
dim Afilespec as FSSpec
menuid = menu(_menuID)
itemid = menu(_itemID)
select case menuid
case 1
select case itemid'File Menu
case 1'Menu "OPEN"
Afile$ = files$(_FSSpecOpen,,"file to test",Afilespec)
k = fn FBFileWritable( Afilespec )
long if k
print "I Can write to """;Afile$;""" Cool..."
xelse
print "Can't write to """;Afile$;""" Drat..."
end if
case 3 : end'menu "QUIT"
end select
end select
menu
end fn
'~'1
clear local fn InitializeGUI
gFBUseNavServices = _zTrue
menu 1, 0 , _enable , "File"
menu 1, 1 , _enable , "Open╔/O;(-;Quit/Q"
window 1,"TEST",(10,50)-(300,300)
text _monaco,9
end fn
'~'1
fn InitializeGUI
on menu fn doMenu
'~'1
do
handleevents
until 0
'~'1
end
'-------------------------- End Test Program --------------------------